package com.zzjson.design.proxy.cglib;

import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2018 rollBall team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : cn.zzjson.design.proxy.cglib</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2018年12月03日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class MeiPo implements MethodInterceptor {
    public Object getInstance(Class objClass) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(objClass);
        enhancer.setCallback(this);
        return enhancer.create();
    }

    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        System.out.println("----------");
        methodProxy.invokeSuper(obj, args);
        System.out.println("------------");
        return null;
    }
}